//
//  MyPhoneKey.m
//  FloatClouds
//
//  Created by 黄威 on 16/8/26.
//  Copyright © 2016年 黄威. All rights reserved.
//

#import "MyPhoneKey.h"
#import "NSString+HVV.h"
@implementation MyPhoneKey



- (instancetype)initKEY{

   self = [super init];
    
    if (self) {
        
        
        NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        
        NSString *pathStr = [[path lastObject]stringByAppendingPathComponent:@"Key.TXT"];
        
        self.Key = [NSString stringWithContentsOfFile:pathStr encoding:NSUTF8StringEncoding error:nil];
        
        
        if (self.Key) {
             return self;
        }else{
        
            NSString *key = [NSString random40bitString];
            
        [key writeToFile:pathStr atomically:YES encoding:NSUTF8StringEncoding error:nil];
            
        self.Key = [NSString stringWithContentsOfFile:pathStr encoding:NSUTF8StringEncoding error:nil];
        
        }
  
    }

    return self;

}

+ (NSString *)getKEY{

    NSString *key = [[self alloc]initKEY];
    
    return key;
    

}

-(NSString *)description{

return [NSString stringWithFormat:@"%@",_Key];
    
    

}

@end
